<?php
	$staticPlugin = new Plugin('Static Sidebar Content');
	$staticPlugin->Author('Ramblingwood, USA.');
	$staticPlugin->Description( 'This allows you to have static content blocks dynamically placed in the sidebar.' );
	$staticPlugin->version( '0.1' );
	$staticPlugin->addInterface('staticPlugin_Interface');
	$staticPlugin->addSidebarBlock('Static Content', 'staticPlugin_Sidebar');

	if(file_exists(BASE_URL.'includes/admin/editors/fckeditor/fckeditor.php')) {
		include(BASE_URL.'includes/admin/editors/fckeditor/fckeditor.php');
		$rte = true;
	}
	else {
		$rte = false;
	}
	
	function staticPlugin_Sidebar () {
		global $staticPlugin;
		echo eval('?>'.stripcslashes($staticPlugin->getOption('content')));
	}
	
	function staticPlugin_Interface () {
		global $staticPlugin, $rte;
		if($_POST['save']) {
			if($staticPlugin->updateOption('content', sanitize_sql_string($_POST['content'])))
				echo $staticPlugin->message('success', 'Content Saved', 'Woohoo!');
			else
				echo $staticPlugin->message('error', 'Hmmm...Something didn\'t work...', 'Please try again.');
			$content = $_POST['content'];
		}
		else {
			$content = $staticPlugin->getOption('content');
		}
		if($rte == true) {
			$FCKeditor_content = new FCKeditor('content') ;
			$FCKeditor_content->BasePath = THEME_URL.'includes/admin/editors/fckeditor/';
			$FCKeditor_content->Value =stripcslashes($content);
			$FCKeditor_content->Width = '100%' ;
			$FCKeditor_content->Height = '350' ;
			$textarea = $FCKeditor_content->CreateHtml();
		}
		else {
			$textarea = '<textarea name="content" id="editContent" rows="20" cols="50"></textarea>';
		}
		echo <<<EOT
	<form action="{$staticPlugin->VISUAL_ROOT}admin.php?page=plugins&interface=static-sidebar-content" method="post">
		<fieldset>
			<h2>Static Content in Sidebar Settings</h2>
			<div class="form-row">
				<label for="content">Content<span class="small gray">If it is enabled in the sidebar, this is what will show.</span></label>
				<span>
					{$textarea}
				</span>
			</div>
			<div class="form-row form-row-last">
				<label for="save">&nbsp;</label>
				<span>
					<input name='save' value='Save' type="submit" />
				</span>
			</div>
		</fieldset>
	</form>
EOT;
	}
?>